package com.liangzhong.modules.ladderMatch.commamd
{
	import com.liangzhong.constants.NotificationConstants;
	import com.liangzhong.proxy.ladderMatch.LadderMatchProxy;
	import com.liangzhong.proxyconstant.ladderMatch.LadderMatchConst;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	public class LadderMatchCommand extends SimpleCommand
	{
		public function LadderMatchCommand()
		{
			super();
		}
		override public function execute(notification:INotification):void
		{
			var proxy:LadderMatchProxy
			switch(notification.getName())
			{
				case LadderMatchConst.LADDERMATCH_MEDIATORTOCOMMAND:
					mediatorNotification(notification);
					break;
				case NotificationConstants.MATCH_START://比赛开始
				{
					proxy = facade.retrieveProxy(LadderMatchProxy.PROXYNAME) as LadderMatchProxy;
					proxy.ladderMatchStart(notification.getBody());
					break;
				}
				case NotificationConstants.LADDER_MATCH_END://比赛结束
				{
					//mainView.showMainUI();
					proxy = facade.retrieveProxy(LadderMatchProxy.PROXYNAME) as LadderMatchProxy;
					proxy.ladderMatchEnd(notification.getBody());
					break;
				}
			}
			
		}
		/**
		 * Mediator -->Command 通知
		 * @param notification
		 * 
		 */		
		private function mediatorNotification(notification:INotification):void
		{
			var proxy:LadderMatchProxy = facade.retrieveProxy(LadderMatchProxy.PROXYNAME) as LadderMatchProxy;
			switch(notification.getType())
			{
				case LadderMatchConst.MATCH_STATUC:
					proxy.matchStatuc(notification.getBody());
					break;
				case LadderMatchConst.APPLYLIST:
					proxy.applyList(notification.getBody());
					break;
				case LadderMatchConst.TOP_10_LIST:
					proxy.requestTopList();
					break;
				case LadderMatchConst.ADD_FIGHT_TIME:
					proxy.requestAddFightTime();
					break;
				case LadderMatchConst.MORE_LADDER_RANK:
					proxy.requestMoreLadderRank();
					break;
				case LadderMatchConst.EXCHANGE:
					proxy.requestExchange(notification.getBody());
					break;
			}
		}
	}
}